﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Configuration;
using System.Security.Cryptography;

namespace ZG_member
{
    public partial class LoseCardPass : Form
    {
        public LoseCardPass(string memId)
        {
            InitializeComponent();
            skinEngine1.SkinFile = Application.StartupPath + ConfigurationManager.AppSettings["Skin"];
            this.Opacity = 0;
            memberId = memId;
        }
        string memberId = "";
        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Left += 2;
            this.Opacity += 0.1;
            if (Opacity == 1)
            {
                this.timer1.Stop();

            }
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            this.Top = this.Top + 10;
            this.Opacity = this.Opacity - 0.06;
            if (Opacity <= 0)
            {
                this.timer2.Stop();
                this.Close();
            }
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void LoseCardPass_Load(object sender, EventArgs e)
        {
            this.timer1.Start();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            if (this.textBox1.Text != this.textBox2.Text)
            {
                MessageBox.Show("两次密码不一致,请重新输入");
                return;
            }
            BLL.memberInfo member = new BLL.memberInfo();
            Model.memberInfo memberMode = new Model.memberInfo();
            memberMode= member.GetModels(memberId);
            MD5 md5 = new MD5CryptoServiceProvider();
            byte[] bt = Encoding.Default.GetBytes(this.textBox2.Text);
            bt = md5.ComputeHash(bt);
            string passWord = "";
            passWord = BitConverter.ToString(bt).Replace("-", "");
            if (passWord == memberMode.pwd)
            {
                LoseCardForm.pass = true;
                this.Close();
            }
            this.Close();
        }

        private void LoseCardPass_FormClosing(object sender, FormClosingEventArgs e)
        {
            this.timer2.Start();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.timer2.Start();
        }
    }
}
